home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 18.1 KB | 562 lines | [TEXT/MPS ] |
- // UEditionDocument.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UEDITIONDOCUMENT__
- #define __UEDITIONDOCUMENT__
-
- // MacApp
-
- #ifndef __UADORNERS__
- #include "UAdorners.h"
- #endif
-
- #ifndef __UBEHAVIOR__
- #include "UBehavior.h"
- #endif
-
- #ifndef __UCOMMAND__
- #include "UCommand.h"
- #endif
-
- #ifndef __UFILEBASEDDOCUMENT__
- #include "UFileBasedDocument.h"
- #endif
-
- #ifndef __UGEOMETRY__
- #include "UGeometry.h"
- #endif
-
- #ifndef __ULISTITERATOR__
- #include "UListIterator.h"
- #endif
-
- // Toolbox
-
- #ifndef __EDITIONS__
- #include <Editions.h>
- #endif
-
-
- //----------------------------------------------------------------------------------------
- // Edition Manager menu command constants
- //----------------------------------------------------------------------------------------
-
- const CommandNumber cCreatePublisher = 601; // the user has selected "Create
- // Publisher" from the Edit menu
-
- const CommandNumber cSubscribeTo = 602; // the user has selected Subscribe to from
- // the Edit menu
-
- const CommandNumber cOptions = 603; // the user has selected a publisher in
- // the document and then selected
- // Publisher Options from the Edit menu,
- // OR, the user has selected a subscriber
- // in the document and then selected
- // Subscriber Options from the Edit menu
-
- const CommandNumber cBorders = 604; // the user has selected Show/ Hide Borders
- // from the Edit menu
-
- const CommandNumber cStopAllEditions = 605; // the user has selected Stop all Editions
- // from the Edit menu
-
- //----------------------------------------------------------------------------------------
- // Edition Manager command constants
- //----------------------------------------------------------------------------------------
-
- const CommandNumber cCancelPublisher = 606; // the user canceled this publisher
-
- const CommandNumber cCancelSubscriber = 607; // the user canceled this subscriber
-
- //----------------------------------------------------------------------------------------
- // miscellaneous constants
- //----------------------------------------------------------------------------------------
-
- const IDType kSectionBehavior = 'sect';
-
- const IDType kSubscriberAdornerID = 'subs';
-
- const IDType kPublisherAdornerID = 'publ';
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class TDesignator;
- class TFile;
- class TList;
- class TPublisher;
- class TSection;
- class TSectionList;
- class TSubscriber;
- class TView;
- class TEditionDocument;
-
-
- //----------------------------------------------------------------------------------------
- // CSectionIterator
- //----------------------------------------------------------------------------------------
-
- class CSectionIterator : public CObjectIterator
- {
- public:
- CSectionIterator(TEditionDocument* itsDocument,
- ArrayIndex itsLowBound, ArrayIndex itsHighBound,
- Boolean itsForward);
-
- CSectionIterator(TEditionDocument* itsDocument, Boolean itsForward);
-
- CSectionIterator(TEditionDocument* itsDocument);
-
- CSectionIterator(TSectionList* itsSectionList);
-
- virtual ~CSectionIterator();
-
- TSection* CurrentSection();
- // returns the current section
-
- TSection* FirstSection();
- // Resets the iteration to begin again and return the first section in the iteration
-
- TSection* NextSection();
- // advances the iteration and then returns the section
- };
-
-
- //----------------------------------------------------------------------------------------
- // TFileBasedDocument
- //----------------------------------------------------------------------------------------
-
- class TEditionDocument : public TFileBasedDocument
- {
- MA_DECLARE_CLASS;
-
- public:
- TSectionList* fSectionList; // list of TSection objects
-
- Boolean fStopAllEditions; // false by default
-
- Boolean fShowSectionBorders; // true by default
-
- Boolean fNewPublishers; // are there any new publishers?
-
- short fNextEditionNumber; // number used in "Untitled-n"
-
- OSType fEditionCreator; // creator for publisher edition container
- // file
-
- //------------------------------------------------------------------------------------
- // constructor/destructor methods
- //------------------------------------------------------------------------------------
-
- TEditionDocument();
- // Constructor
-
- void IEditionDocument(TFile* itsFile,
- const OSType itsScrapType,
- const OSType editionCreator);
- // initializes this object
-
- virtual ~TEditionDocument();
- // frees this object
-
- virtual void FreeData();
- // frees the fSectionList
-
-
- //------------------------------------------------------------------------------------
- // saving documents
- //------------------------------------------------------------------------------------
-
- virtual void Close();
- // For the case in which the document's change count = 0, but there are "dirty"
- // sections, need to ask the user whether to save the document.
-
- virtual short PoseNewPublishersAlert();
- // Warns the user that he is about to close a document that hasn't been saved in
- // which he has created a new publisher. The user hasn't modified the document's
- // data.
-
- virtual short PoseMultPublishersAlert(TSection* aSection);
- // Warns the user that he is creating multiple publishers to the same edition.
-
- virtual short PoseSavingMultPublishersAlert(TSection* aSection);
- // Warns the user that he is saving multiple publishers to the same edition.
-
- virtual void Abandon();
- // Calls TSection.Delete on all dirty sections.
-
- virtual void DoNeedDiskSpace(TFile* itsFile,
- long& dataForkBytes,
- long& rsrcForkBytes);
- // Bytes required to store SAVE file(s) on disk. When called, both parameters are
- // set to 0 for you.
-
- virtual void DoWrite(TFile* aFile, Boolean makingCopy);
- // writes out the sections and edition doc settings
-
- virtual void DoWriteSettings(TFile* aFile);
- // writes out the edition doc settings (Show/ Hide Border, Stop All Editions)
-
- virtual void DoRead(TFile* aFile, Boolean forPrinting);
- // reads in the sections and edition doc settings
-
- virtual void DoReadSettings(TFile* aFile);
- // reads in the edition doc settings (Show/ Hide Border, Stop All Editions)
-
- virtual void DoReadPublisher(TFile* aFile, short theID);
- // reads in a given publisher
-
- virtual void DoReadSubscriber(TFile* aFile, short theID);
- // reads in a given subscriber
-
- //------------------------------------------------------------------------------------
- // Revert
- //------------------------------------------------------------------------------------
-
- virtual void RevertDocument();
- // Calls Abandon() and then Inherited.
-
- //------------------------------------------------------------------------------------
- // Accessors
- //------------------------------------------------------------------------------------
-
- virtual void SetSectionBorders(Boolean state, Boolean invalidate);
- // sets the value of fShowSectionBorders to state and invalidates the document's windows
- // if "invalidate" is true
-
- virtual void SetStopAllEditions(Boolean state);
- // sets the value of fStopAllEditions to state and reads in any new subscribers if "state"
- // is true
-
- virtual OSType GetEditionCreatorSignature();
- // returns the creator signature used for the edition container file
-
-
- //------------------------------------------------------------------------------------
- // menu management methods
- //------------------------------------------------------------------------------------
-
- virtual void DoMenuCommand(CommandNumber aCommandNumber);
-
- virtual void DoSetupMenus();
-
- virtual Boolean CanPublishSelection();
-
- virtual Boolean CanSubscribe();
-
-
- //------------------------------------------------------------------------------------
- // edition manager support
- //------------------------------------------------------------------------------------
-
- virtual void DoAddSectionBehavior(TView* itsView);
- // creates and adds a TSectionBehavior to implement the Ed Mgr shortcuts.
-
- virtual void DoNewPublisher();
-
- virtual TPublisher* DoMakePublisher(TDesignator* itsDesignator,
- SectionHandle itsSectionHandle,
- short itsSectionID);
-
-
- virtual void DoNewPublisherDialog(NewPublisherReply& reply);
-
- virtual void DoMakePreview(TDesignator* itsDesignator,
- FormatType& previewFormat,
- Handle& preview);
-
- virtual void DisposeOfPreview(NewPublisherReply& reply);
- // Called from DoNewPublisher. Default implementation diposes of the view
- // if it is of type 'TEXT' or 'PICT'. Override this method to dispose of
- // your own special preview type.
-
- virtual void DoNewSubscriber();
-
- virtual TSubscriber* DoMakeSubscriber(TDesignator* itsDesignator,
- SectionHandle itsSectionHandle,
- short itsSectionID);
-
- virtual void DoNewSubscriberDialog(NewSubscriberReply& reply);
-
- virtual void DoSectionOptions();
- // poses the publisher or subscriber options dialog depending on what
- // GetSelectedSection returns
-
- virtual FormatType GetPublishPreference();
- // return 'PICT' to publish 'PICT' first, return 'TEXT' to publish 'TEXT' first
-
- virtual SignedByte GetSubscriberFormatsMask();
-
- virtual void GetNextEditionName(CStr63& editionName);
-
- virtual void DoPublisherOptions(TPublisher* aPublisher);
-
- virtual void DoPublisherOptionsDialog(SectionOptionsReply& reply);
-
- virtual void DoSubscriberOptions(TSubscriber* aSubscriber);
-
- virtual void DoSubscriberOptionsDialog(SectionOptionsReply& reply);
-
-
- //------------------------------------------------------------------------------------
- // section management
- //------------------------------------------------------------------------------------
-
- virtual void AddSection(TSection* aSection);
- // adds the section to this document's section list
-
- virtual void AddSectionAndBorder(TSection* aSection);
- // adds the section to this document's section list and calls DoAddBorder to add
- // its border. This should be used when the view hierarchy has already been
- // constructed and we know that have a view to attach the border to.
-
- virtual void CancelSection(TSection* aSection, Boolean cancel);
- // calls aSection->CancelSection(cancel);
-
- virtual TSection* GetSelectedSection();
- // This returns the currently selected section, if any. Returns NULL if > 1 section
- // is currently selected.
-
- virtual short GetUniqueSectRsrcID();
- // returns a unique 'sect' resource id for use as both the section ID and as the
- // rsrc ID
-
- virtual Boolean IsSectionSelected(TSection* aSection);
- // returns true if the given section is in the user selection
-
- virtual void RemoveSection(TSection* aSection);
- // this method should mark document as changed so that document removes this
- // section when saved (e.g. sipAlways)
-
- //------------------------------------------------------------------------------------
- // border management
- //------------------------------------------------------------------------------------
-
- virtual void DoPostMakeViews(Boolean forPrinting);
- // Calls DoAddBorder for all sections and then calls Inherited::DoPostMakeViews().
-
- virtual void DoAddBorder(TSection* aSection);
- // subclasses should override this to create a border to adorn this section
-
- virtual void DoAdjustBorder(TSection* aSection);
- // subclasses should override this to adjust the border which adorn this section
-
- virtual void DoDeleteBorder(TSection* aSection);
- // subclasses should override this to remove the border adorning this section
-
- virtual Boolean IsBorderShown(TSection* aSection);
- // returns true if (borders are shown) or (the user selection contains aSection)
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TNewSubscriberCommand: TNewSubscriberCommand creates a new subscriber and marks the
- // document as changed.
- //----------------------------------------------------------------------------------------
-
- class TNewSubscriberCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TNewSubscriberCommand();
- // Empty constructor to satisfy compiler.
- virtual ~TNewSubscriberCommand();
- // Destructor
-
- void INewSubscriberCommand(CommandNumber itsCommandNumber, TDocument* itsDocument);
- // initialize this command
-
- virtual void DoIt();
- // Create a new subscriber
- };
-
-
- //----------------------------------------------------------------------------------------
- // TSectionBorderCommand: TSectionBorderCommand is an undoable command which changes the setting
- // for the show/ hide border option for the current document when the user chooses Hide/
- // Show Borders from the Edit menu
- //----------------------------------------------------------------------------------------
-
- class TSectionBorderCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- Boolean fShowSectionBorders; // value to set
-
- TSectionBorderCommand();
- // Empty constructor to satisfy compiler.
- virtual ~TSectionBorderCommand();
- // Destructor
-
- void ISectionBorderCommand(CommandNumber itsCommandNumber, TDocument* itsDocument);
- // initialize this command
-
- virtual void DoIt();
- // tell the document to show or hide the borders for all sections
-
- virtual void UndoIt();
- // tell the document to undo show or hide the borders for all sections
- };
-
-
- //----------------------------------------------------------------------------------------
- // TStopAllEditionsCommand: TStopAllEditionsCommand is an undoable command gets posted when the
- // user chooses Stop all Editions from the Edit menu. This command toggles the setting for
- // the documents fStopAllEditions field.
- //----------------------------------------------------------------------------------------
-
- class TStopAllEditionsCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- Boolean fStopAllEditions; // value to set
-
- TStopAllEditionsCommand();
- // Empty constructor to satisfy compiler.
- virtual ~TStopAllEditionsCommand();
- // Destructor
-
- void IStopAllEditionsCommand(CommandNumber itsCommandNumber,
- TDocument* itsDocument);
- // initialize this command
-
- virtual void DoIt();
- // tell the document to toggle the state of its fStopAllEditions flag
-
- virtual void UndoIt();
- // tell the document to toggle the state of its fStopAllEditions flag
- };
-
-
- //----------------------------------------------------------------------------------------
- // TSectionAdorner: abstract superclass for section adorners
- //----------------------------------------------------------------------------------------
-
- class TSectionAdorner : public TAdorner
- {
- MA_DECLARE_CLASS;
-
- public:
- RgnHandle fBorderRegion; // the region for the section border
-
- TSection* fSection; // the section this adorner adorns
-
- TSectionAdorner();
- // Constructor
-
- void ISectionAdorner(IDType itsID,
- TSection* itsSection,
- RgnHandle itsBorderRegion);
-
- // initializes the section adorner with priority kAdornAfter
-
- virtual ~TSectionAdorner();
- // frees fBorderRegion
-
- virtual void InvalidateAdorner(TView* itsView); // Override
- // Invalidates the adorner in the TAdornerMgr' TView.
-
- virtual void DrawBorder(const Pattern& whichPattern);
- // Draws the adorner's border in the TAdornerMgr' TView.
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // TSubscriberAdorner: A specialized adorner for imaging subscriber borders
- //----------------------------------------------------------------------------------------
-
- class TSubscriberAdorner : public TSectionAdorner
- {
- MA_DECLARE_CLASS;
-
- public:
- TSubscriberAdorner();
- // Empty constructor to satisfy compiler.
- virtual ~TSubscriberAdorner();
- // Destructor
-
- void ISubscriberAdorner(IDType itsID,
- TSubscriber* itsSubscriber,
- RgnHandle itsBorderRegion);
- // initializes the subscriber adorner
-
- virtual void DoHighlightSelection(TView* itsView,
- const VRect& area,
- HLState fromHL,
- HLState toHL); // Override
- // Adorns the selection before the view's DoHighlightSelection.
- };
-
-
- //----------------------------------------------------------------------------------------
- // TPublisherAdorner
- //----------------------------------------------------------------------------------------
-
- class TPublisherAdorner : public TSectionAdorner
- {
- MA_DECLARE_CLASS;
-
- public:
- TPublisherAdorner();
- // Empty constructor to satisfy compiler.
- virtual ~TPublisherAdorner();
- // Destructor
-
- void IPublisherAdorner(IDType itsID,
- TPublisher* itsPublisher,
- RgnHandle itsBorderRegion);
- // initializes the publisher adorner
-
- virtual void DoHighlightSelection(TView* itsView,
- const VRect& area,
- HLState fromHL,
- HLState toHL); // Override
- // Adorns the selection before the view's DoHighlightSelection.
-
- };
-
- //----------------------------------------------------------------------------------------
- // TSectionBehavior
- //----------------------------------------------------------------------------------------
-
- class TSectionBehavior : public TBehavior
- {
- MA_DECLARE_CLASS;
-
- public:
- TSectionBehavior();
- // Empty constructor to satisfy compiler.
- virtual ~TSectionBehavior();
- // Destructor
-
- void ISectionBehavior(IDType itsIdentifier);
-
- virtual Boolean DoMouseCommand(VPoint& theMouse,
- TToolboxEvent* event,
- CPoint hysteresis);
- // Intercepts mouse commands and traps dbl-clicks in sections.
- // By default, calls Inherited.
-
- virtual IDType GetStandardSignature();
- // Returns this class's standard signature.
- };
-
-
- //----------------------------------------------------------------------------------------
- // Externally avaibable routines
- //----------------------------------------------------------------------------------------
-
- extern void InitUEditionDocument();
- // call this routine to initialize this unit.
-
-
- #endif
-
-
-